package com.cellulam.framework.datasource.service;

import com.cellulam.framework.core.auth.UserBasicInfo;
import com.cellulam.framework.core.auth.UserClient;
import com.cellulam.framework.core.model.UpdateUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UpdateUserRequestUtils {
    @Autowired
    private UserClient userClient;

    public void fillCreateUser(UpdateUser request) {
        UserBasicInfo user = this.userClient.getUser();

        if (user != null) {
            request.setCreateUser(user.getUserId());
            request.setCreateUserName(user.getRealName());
            request.setUpdateUser(user.getUserId());
            request.setUpdateUserName(user.getRealName());
        }
    }

    public void fillUpdateUser(UpdateUser request) {
        UserBasicInfo user = this.userClient.getUser();

        if (user != null) {
            request.setUpdateUser(user.getUserId());
            request.setUpdateUserName(user.getRealName());
        }
    }
}
